package com.ysten.basic.bean.repository.system;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.ysten.basic.bean.entity.system.RoleMenuRel;

 

public interface RoleMenuRelDao extends PagingAndSortingRepository<RoleMenuRel, Long>,
    JpaSpecificationExecutor<RoleMenuRel>
{
    /**
     * 根据菜单Id和角色Id删除按钮权限 <功能详细描述>
     * 
     * @param menuId
     * @param roleId
     * @see [类、类#方法、类#成员]
     */
    @Modifying
    @Query("delete from RoleMenuRel u where u.menuId=?1")
    void deleteByMenuId(Long menuId);
    
    List<RoleMenuRel> findByRoleId(Long roleId);

    @Modifying
    @Query("delete from RoleMenuRel u where u.roleId=?1")
    void deleteByRoleId(Long id);

    /** <一句话功能简述>
     * <功能详细描述>
     * @param roleIdList
     * @return
     * @see [类、类#方法、类#成员]
     */
    @Query("select distinct(menuId) from  RoleMenuRel u where u.roleId in(?1)")
    List<Long> findMenuIdByRoleId(List<Long> roleIdList);
}
